import 'package:flutter/material.dart';

//class JoyHomeEmptyWidget extends StatefulWidget{

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../config/app_colors.dart';


class JoyHomeEmptyWidget extends StatefulWidget{

  final String messageError;
  final bool isNetError;
  final String errorImagePath;
  final String? btnTitle;
  final bool? isShowBtn;
  final Function tapOnCallBack;
  const JoyHomeEmptyWidget({
    required this.messageError,
    this.isShowBtn = true,
    required this.isNetError,
    required this.errorImagePath,
    this.btnTitle = "No Data",
    required this.tapOnCallBack
  });


  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return JoyHomeEmptyWidgetState();
  }

}
class JoyHomeEmptyWidgetState extends State<JoyHomeEmptyWidget>{

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return showEmptyOrder();
  }

  Widget showEmptyOrder(){

    return Container(
      color: AppColors.background,
      child: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            SizedBox(height: 20,),
            Visibility(
              child: Container(
                width: 134.w,
                height: 120.w,
                child: Image.asset(widget.errorImagePath,),
              ),
              visible: widget.errorImagePath != "",
            ),
            SizedBox(height: 20,),
            Text(widget.messageError,style: TextStyle(fontSize: 15.sp,color: Color(0xFF808080)),),
            SizedBox(height: 10,),
            Visibility(
              child: submitButton(context),
              visible: widget.isShowBtn??true,
            )
          ],
        ),
      ),
    );
  }

  Widget submitButton(BuildContext context){
    String btnTitleStr =  "Retry";
    if(widget.isNetError){
      btnTitleStr =  "Retry";
    }else{
      btnTitleStr =  "Refresh";
    }
    return InkWell(
      child: Container(
          height: 50.w,
          width: ScreenUtil().screenWidth - 100.w,
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(30),
            gradient: LinearGradient(
              begin: Alignment.centerLeft,
              end: Alignment.centerRight,
              colors: [
                Colors.blue,Colors.blue
              ],
            ),
          ),
          child:Center(
            child: Text(
              btnTitleStr,
              style: TextStyle(
                  color: Colors.white,
                  fontWeight: FontWeight.w300,
                  fontSize: 16.sp
              ),
            ),
          )
      ),
      onTap: (){
        widget.tapOnCallBack();
      },
    );
  }


}
